package com.xwj.config;

import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.RetryNTimes;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * zookeeper配置
 * @author xwj
 * @date 2020/5/6
 */
@Configuration
public class ZkConfig {
    @Value("${zk.host}")
    private String host;
    @Bean
    public CuratorFramework curatorFramework() {
        CuratorFramework curatorFramework = CuratorFrameworkFactory.builder()
                .connectString(host).retryPolicy(new RetryNTimes(5, 1000)).build();
        curatorFramework.start();
        return curatorFramework;
    }

}
